import http from "./http";

export const download=async (fileName:string)=>{

    //响应的数据类型 axios responseType: 'blob'

    const res= await http.post<Blob>("/api/elderlyFiles/downloadFile",{fileName},{responseType: 'blob'});

    
    const url = URL.createObjectURL(res.data);
    
    const a = document.createElement('a');
    a.href = url;
    a.download = fileName.split('/').pop()!;
    a.style.display = 'none';
    document.body.appendChild(a);
    a.click();
    document.body.removeChild(a);

  
  }
  